function formatZero(data) {
	let num = parseInt(data);
	if (num >= 0) {
		if (num < 10) {
			return "0" + num;
		} else if (num >= 10) {
			return num.toString();
		}
	} else if (num < 0) {
		console.error("传入了负数");
		return "";
	} else {
		console.error("传入了非数");
		return "";
	}
}
/**
 * @param {Boolean} detail -
 * - false: 返回 年-月-日
 * - true: 返回 年-月-日 时:分:秒 */
export function getDate(detail) {
	let now = new Date();
	let year = now.getFullYear();
	let month = now.getMonth() + 1;
	let date = now.getDate();
	// let day = now.getDay(); //得到周几
	let hour = now.getHours(); //得到小时
	let minu = now.getMinutes(); //得到分钟
	let sec = now.getSeconds(); //得到秒
	let _time;
	if (detail) {
		_time =
			year +
			"-" +
			formatZero(month) +
			"-" +
			formatZero(date) +
			" " +
			formatZero(hour) +
			":" +
			formatZero(minu) +
			":" +
			formatZero(sec);
	} else {
		_time = year + "-" + formatZero(month) + "-" + formatZero(date);
	}
	return _time;
}
// console.log("当前日期为: " + getDate(true));
// console.log("当前日期为: " + getDate(false));
